EXTRA_DIST = asciidoc.conf
CLEANFILES =

if HAVE_DOXYGEN
SUBDIRS = doxygen
endif

MAN3 = \
	   can_init.3 \
	   can_setdebug.3 \
	   can_send.3 \
	   can_recv.3 \
	   can_setfilter.3 \
	   can_cycle2snd.3 \
	   can_exit.3


MAN_DOC = $(MAN3)

MAN_TXT = $(MAN3:%.3=%.txt)
MAN_HTML = $(MAN_TXT:%.txt=%.html)

if INSTALL_MAN
dist_man_MANS = $(MAN_DOC)
doc: $(MAN_DOC)
endif

EXTRA_DIST += $(MAN_TXT)
if BUILD_DOC
EXTRA_DIST += $(MAN_HTML)
html: $(MAN_HTML)
endif

MAINTAINERCLEANFILES = $(MAN_DOC) $(MAN_HTML)

dist-hook: $(MAN_DOC) $(MAN_HTML)

if BUILD_DOC
SUFFIXES=.html .txt .xml .1 .3

.txt.html:
	asciidoc -d manpage -b xhtml11 -f asciidoc.conf \
		-alibcanbus_version=@LIBCANBUSBUS_VERSION@ $<
.txt.xml:
	asciidoc -d manpage -b docbook -f asciidoc.conf \
		-alibcanbus_version=@LIBCANBUS_VERSION@ $<
.xml.1:
	xmlto man $<
.xml.3:
	xmlto man $<
.xml.7:
	xmlto man $<

CLEANFILES += *.1 *.3 *.html
endif
